package com.epam.training.concurrency.second.task5;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Test thread for transfer money in class Bank
 * 
 * @author bogdan
 *
 */
public class TestThread extends Thread {
	private Bank bank;
	private Account fromAccount;
	private Account toAccount;
	private int amount;

	/**
	 * Main counstuctor
	 * 
	 * @param bank
	 * @param fromAccount
	 * @param toAccount
	 * @param amount
	 */
	TestThread(Bank bank, Account fromAccount, Account toAccount, int amount) {
		this.bank = bank;
		this.fromAccount = fromAccount;
		this.toAccount = toAccount;
		this.amount = amount;
	}

	@Override
	public void run() {
		try {
			bank.transfer(fromAccount, toAccount, amount);
		} catch (Exception e) {
			Logger.getLogger(TestThread.class.getName()).log(Level.WARNING,
					null, e);
		}
	}
}
